import request from '../../request'

// 投资小结相关接口
export default {
    // 获取投资小结列表
    getSummaryList() {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/summary/list',
            method: 'get'
        })
    },

    // 添加投资小结
    addSummary(data: {
        date: string,
        content: string
    }) {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/summary/add',
            method: 'post',
            data
        })
    },

    // 更新投资小结
    updateSummary(data: {
        id: number,
        date: string,
        content: string
    }) {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/summary/update',
            method: 'put',
            data
        })
    },

    // 删除投资小结
    deleteSummary(id: number) {
        return request({
            url: `http://cylyxsz.w1.luyouxia.net/blog/api/investment/summary/delete/${id}`,
            method: 'delete'
        })
    },

    // 获取持仓列表
    getPortfolioList() {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/list',
            method: 'get'
        })
    },

    // 获取已清仓列表
    getClosedList() {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/closed',
            method: 'get'
        })
    },

    // 获取持仓统计数据
    getPortfolioStats() {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/stats',
            method: 'get'
        })
    },

    // 更新持仓统计数据
    updatePortfolioStats(data: {
        total_assets: number;
        total_investment: number;
    }) {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/stats/update',
            method: 'put',
            data
        })
    },

    // 添加持仓
    addHolding(data: {
        name: string;
        code: string;
        amount: number;
        cost: number;
        current: number;
    }) {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/add',
            method: 'post',
            data
        })
    },

    // 更新持仓
    updateHolding(data: {
        id: number;
        name: string;
        code: string;
        amount: number;
        cost: number;
        current: number;
    }) {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/update',
            method: 'put',
            data
        })
    },

    // 删除持仓
    deleteHolding(id: number) {
        return request({
            url: `http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/delete/${id}`,
            method: 'delete'
        })
    },

    // 移动到已清仓列表
    moveToClosedList(data: {
        id: number;
        sell_price: number;
        hold_days: number;
    }) {
        return request({
            url: 'http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/move-to-closed',
            method: 'post',
            data
        })
    },

    // 删除已清仓记录
    deleteClosed(id: number) {
        return request({
            url: `http://cylyxsz.w1.luyouxia.net/blog/api/investment/portfolio/closed/delete/${id}`,
            method: 'delete'
        })
    }
} 